//
//  KTUIUtils.swift
//  KOLToken
//
//  Created by yangsan on 2020/2/27.
//  Copyright © 2020 iOS-team. All rights reserved.
//

import UIKit
struct FastLabel {
    public func fastCreateLabel(text:String!, color:UIColor?, alignment:NSTextAlignment?, textColor: UIColor, font:UIFont) -> UILabel {
        let label = UILabel.init()
        label.text = text
        label.backgroundColor = color ?? UIColor.clear
        label.textColor = textColor
        label.font = font
        label.textAlignment = alignment ?? NSTextAlignment.center
        label.adjustsFontSizeToFitWidth = true
        return label
    }
}

struct FastButton {
    
    public func fastCreateTitleButton (title: String,titleColor: UIColor, titleFont:UIFont, bgColor: UIColor?, block: @escaping (Any) -> Void) -> UIButton{
        let button = UIButton.init(type: UIButton.ButtonType.custom)
        button.setTitle(title, for: UIControl.State.normal)
        button.setTitleColor(titleColor, for: UIControl.State.normal)
        button.titleLabel?.font = titleFont
        button.backgroundColor = bgColor ?? UIColor.clear
        button.addBlock(for: UIControl.Event.touchUpInside, block: block)
        return button
    }
    
    public func fastCreateImageButton (image: UIImage, highlightImage: UIImage, block: @escaping (Any) -> Void) -> UIButton{
        let button = UIButton.init(type: UIButton.ButtonType.custom)
        button.setImage(image, for: UIControl.State.normal)
        button.setImage(highlightImage, for: UIControl.State.highlighted)
        button.addBlock(for: UIControl.Event.touchUpInside, block: block)
        return button
    }
}

public enum KTAppFrame {
    
    static let kScreenBounds = UIScreen.main.bounds
    
    // 屏幕宽度
    static let kScreenWidth = kScreenBounds.size.width
    
    // 屏幕高度
    static let kScreenHeight = kScreenBounds.size.height
    
    // iPhone4
    static let iPhone4 = kScreenHeight  < 568 ? true : false
    
    // iPhone 5
    static let iPhone5 = kScreenHeight  == 568 ? true : false
    
    // iPhone 6
    static let iPhone6 = kScreenHeight  == 667 ? true : false
    
    // iphone 6P
    static let iPhone6P = kScreenHeight == 736 ? true : false
    
    // iphone X
    static let iPhoneX = kScreenHeight == 812 ? true : false
    
    // iphone X iphone XR iphone XS iphone XSMax
    static let iPhoneX_XR_XS = kScreenHeight >= 812 ? true : false
    
    // navigationBarHeight
    static let kNavigationBarHeight : CGFloat = iPhoneX_XR_XS ? 88 : 64
    
    // safeArea
    static let kSafeAreaHeight : CGFloat = iPhoneX_XR_XS ? 34 : 0
    
    // tabBarHeight
    static let kTabBarHeight : CGFloat = iPhoneX_XR_XS ? 49 + 34 : 49
    
    /** 如果是iPhoneX按照Plus 尺寸计算比例 */
    static let Scale_Height = iPhoneX ? 736.0/667.0 : kScreenHeight / 667
    static let Scale_Width = kScreenWidth / 375
    
}


